/**
 * 查询数据集
 * @see http://iclient.supermap.io/libs/iclient8c/apidoc/files/SuperMap/REST/Query/QueryBySQLService-js.html
 * @param {*} options
 */
export function queryBySQLService ({ url, select, where, dataSource, dataSet }) {
  var queryParam = new SuperMap.REST.FilterParameter({
    attributeFilter: where,
    fields: select
  })
  var queryBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({
    queryParameter: queryParam,
    toIndex: -1,
    datasetNames: [`${dataSource}:${dataSet}`]
  })
  return new Promise((resolve, reject) => {
    var queryBySQLService = new SuperMap.REST.GetFeaturesBySQLService(url, {
      eventListeners: {
        'processCompleted': resolve,
        'processFailed': reject
      }
    })
    queryBySQLService.processAsync(queryBySQLParams)
  })
}
